package com.bestcem.xm.survey;

import com.bestcem.xm.common.core.annotation.EnableCustomConfig;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.retry.annotation.EnableRetry;

import java.util.concurrent.TimeUnit;

@EnableCustomConfig
@SpringBootApplication
@EnableRetry
@ComponentScan(value = {
        "com.bestcem.xm.common.core",
        "com.bestcem.xm.component",
        "com.bestcem.xm.survey"
}, excludeFilters = {
        @ComponentScan.Filter(type = FilterType.REGEX, pattern = "com.bestcem.xm.common.core.sign.*")
})
public class BestcemApplication {

    public static void main(String[] args) {
        SpringApplication.run(BestcemApplication.class, args);
    }

    @Bean("xmSurveyCache")
    public Cache<String, Object> xmSurveyCache() {
        return Caffeine.newBuilder()
                .initialCapacity(128)//初始大小
                .maximumSize(1024)//最大数量
                .expireAfterWrite(Long.MAX_VALUE, TimeUnit.DAYS)//等于永不过期
                .build();
    }
}
